package com.party.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;

import com.party.domain.Services;
/**
 * 
 * @author Caizhf
 * @date 2017年5月26日上午9:39:54
 * @version v.0.1
 * @email 1115054416@qq.com 
 *
 * <p>Description: 服务</p>
 *
 */
public interface ServicesMapper {
	Services findById(int sid);
	
	int add(Services s);
	
	int update(Services s);
	
	int deleteById(int sid);
	
	/**
	 * 
	 * @param product_type 产品类型：是达人服务还是包车
	 * @param mold_name	   服务分类：达人服务-是厨师还是摄影师||租车服务-是大巴车还是中巴车
	 * @return 需要分页
	 */
	@Select("SELECT * FROM product p INNER JOIN services s"+
		" ON s.product_id=p.pid"+
		" INNER JOIN mold m"+ 
		" ON m.mid=s.mold_id"+
		" WHERE p.product_type=#{product_type}"+ 
		" AND m.mold_name=#{mold_name}"+
		" LIMIT #{pageStart},#{pageSize}"
		)
	@ResultMap("com.party.mapper.ServicesMapper.ServicesBaseMapped")
	List<Services> findAll(@Param("product_type")String product_type,@Param("mold_name")String mold_name,@Param("pageStart")int pageStart,@Param("pageSize")int pageSize);

	
	//某个类型与某个分类总记录数
	@Select("SELECT COUNT(*) FROM product p INNER JOIN services s"+
			" ON s.product_id=p.pid"+
			" INNER JOIN mold m"+ 
			" ON m.mid=s.mold_id"+
			" WHERE p.product_type=#{product_type}"+ 
			" AND m.mold_name=#{mold_name}")
	public int getTalentTotleRecord(@Param("product_type")String product_type,@Param("mold_name")String mold_name);
	
}
